package com.weather.controller;

import com.weather.service.MailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/index")
public class SendMailController {

    @Autowired
    private MailService mailService;

//    @Autowired
//    private TemplateEngine templateEngine;

//    @ApiOperation(value = "发送简单邮件", notes = "发送简单邮件")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "sendTo", required = true, value = "接收人"),
//            @ApiImplicitParam(name = "subject", required = false, value = "邮件主题"),
//            @ApiImplicitParam(name = "text", required = false, value = "邮件内容"),
//    })

    @GetMapping("/sendSimpleMail")
    public String sendSimpleMail(@RequestParam String sendTo,
                                      @RequestParam(required = false) String subject,
                                      @RequestParam(required = false) String text) {
        mailService.sendSimpleMail(sendTo, subject, text);
        return "消息已发送";
    }

}
